package my.jwds.p2044;

public class CountMaxOrSubsets {

    public static void main(String[] args) {

        CountMaxOrSubsets obj = new CountMaxOrSubsets();
        long start = System.currentTimeMillis();

        System.out.println(obj.countMaxOrSubsets(new int[]{3,2,1,5}));
        System.out.println("运行时间:" + (System.currentTimeMillis() - start));
    }
    int max,res;
    int nums[];
    public int countMaxOrSubsets(int[] nums) {
        this. nums = nums;
        max = Integer.MIN_VALUE;
        res = 0;
        bfs(0,0);
        return res;
    }


    void bfs(int pos,int num){
        for (int i = pos; i < nums.length; i++) {
            int temp = num | nums[i];
            if (temp > max){
                res = 1;
                max = temp;
            }else if (temp == max){
                res ++;
            }
            bfs(i+1,temp);
        }
    }



}